import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "../components/page/admin/login/index.vue";
import Adminin from "../components/page/admin/adminindex/index.vue";

import Usermsg from "../components/page/admin/usermsg/index.vue";
import Home from "../components/page/admin/home/home.vue";
import Crogoods from "../components/page/admin/goodsmsg/crogoods.vue";
import Ordgoods from "../components/page/admin/goodsmsg/ordgoods.vue";
import Order from "../components/page/admin/order/index.vue";
import  Promsg from "../components/page/admin/promsg/index.vue";
import Paymsg from "../components/page/admin/paymsg/index.vue";
import Logmsg from "../components/page/admin/logmsg/index.vue";
import Cartmsg from "../components/page/admin/cartmsg/index.vue";

import Client from "../components/page/client/Index/index.vue";
import Logins from "../components/page/client/Login/index.vue";
import Resgister from "../components/page/client/Resgister/index.vue";
import Homes from "../components/page/client/Home/index.vue";
import Homes1 from "../components/page/client/Homes/index1.vue";
import Details from "../components/page/client/Details/index.vue";
import Help from "../components/page/client/Help/index.vue";
import Read from "../components/page/client/Read/index.vue";
import Crowd from "../components/page/client/Crowd/index.vue";
import Hot from "../components/page/client/Hot/index.vue";
import News from "../components/page/client/News/index.vue";
import Silde1 from "../components/page/client/Slide/index1.vue";
import Xieyi from "../components/page/client/xieyi/index.vue"
import Shouye from "../components/page/client/shouye/index.vue";
import Mycrowd from "../components/page/client/Mycrowd/index.vue"

// import Details from "../components/page/client/Details/index.vue";
import Crowdde from "../components/page/client/Crowd_detailes/index.vue";
import Tobuy from "../components/page/client/Tobuy/index.vue";
import Cart from "../components/page/client/Cart/index.vue"; 
import Settlement from "../components/page/client/Settlement/index.vue";
import Apply from "../components/page/client/Apply/index.vue";
import Orders from "../components/page/client/Order/index.vue";
import OrdinarySearch from "../components/page/client/Ordinary_search/index.vue";

Vue.use(VueRouter)

const routes = [
  {
      "path" : "/admin",
      "name":"msglogin",
      "components" :{ msglogins:Login}
  },

  
  {
    "path" : "/admin/index",
    "name":"",
    "iconCls": 'el-icon-message',
    "components" :{ adminin:Adminin},
    leaf: true,
    admin:"kang",
    children:[
        {path:"/admin/index/home",
        component:Home,
        name:"首页",
        hidden:true
    }
    ]
 },
 {
    "path" : "/admin/index",
    "name":"",
    "iconCls": 'fa fa-user-circle-o',
    "components" :{ adminin:Adminin},
    leaf: true,
    admin:"kang",
    children:[
        {path:"/admin/index/usermsg",
        component:Usermsg,
        name:"用户管理",
        hidden:true
    }
    ]
 },
 {
    "path" : "/admin/index",
    "name":"商品管理",
    "iconCls": 'fa fa-suitcase',
    admin:"kang",
    "components" :{ adminin:Adminin},
    children:[
        {path:"/admin/index/crogoods",
        component:Crogoods,
        name:"众筹商品管理",
        hidden:true
    },
    {path:"/admin/index/ordgoods",
        component:Ordgoods,
        name:"普通商品管理",
        hidden:true
    }

    ]
 },
 {
    "path" : "/admin/index",
    "name":"",
    "iconCls": 'fa fa-file-text',
    "components" :{ adminin:Adminin},
    leaf: true,
    admin:"kang",
    children:[
        {path:"/admin/index/order",
        component:Order,
        name:"订单管理",
        hidden:true
    }
    ]
 },
//  {
//     "path" : "/admin/index",
//     "name":"",
//     "iconCls": 'fa fa-id-card-o',
//     "components" :{ adminin:Adminin},
//     leaf: true,
//     admin:"kang",
//     children:[
//         {path:"/admin/index/promsg",
//         component:Promsg,
//         name:"热销商品",
//         hidden:true
//     }
//     ]
//  },
//  {
//     "path" : "/admin/index",
//     "name":"",
//     "iconCls": 'fa fa-id-card-o',
//     "components" :{ adminin:Adminin},
//     leaf: true,
//     admin:"kang",
//     children:[
//         {path:"/admin/index/paymsg",
//         component:Paymsg,
//         name:"支付方式",
//         hidden:true
//     }
//     ]
//  },
//  {
//     "path" : "/admin/index",
//     "name":"",
//     "iconCls": 'fa fa-id-card-o',
//     "components" :{ adminin:Adminin},
//     leaf: true,
//     admin:"kang",
//     children:[
//         {path:"/admin/index/logmsg",
//         component:Logmsg,
//         name:"物流管理",
//         hidden:true
//     }
//     ]
//  },
 {
    "path" : "/admin/index",
    "name":"",
    "iconCls": 'fa fa-opencart',
    "components" :{ adminin:Adminin},
    leaf: true,
    admin:"kang",
    children:[
        {path:"/admin/index/cartmsg",
        component:Cartmsg,
        name:"购物车管理",
        hidden:true
    }
    ]
 },
 {
     "path":"/",
     "name":"",
     "components":{
         client:Client
     },
     children:[
        {path:"/",
        components:{index:Homes},
        name:"首页",
        children:[
            {path:"/",
            components:{sear:Homes1},
            name:"首页1"
        },
        {path:"/details",
        components:{sear:Details},
        name:"详情"
    },
    {path:"/cart",
        components:{sear:Cart},
        name:"cart"
    },
    {
        path:"/settlement",
        components:{sear:Settlement},
        name:"settlement"
    },
    {
        "path" : "/order",
        "name":"订单",
        "components" :{ sear:Orders}
     },
     {
        "path" : "/ordinarySearch",
        "name":"搜索结果",
        "components" :{ sear:OrdinarySearch}
     },
        ]
    }
    ]
 },
 {
    "path" : "/login",
    "name":"",
    "components" :{ client:Logins}
 },
 {
    "path" : "/resgister",
    "name":"",
    "components" :{ client:Resgister}
 },
 {
    "path" : "/help",
    "name":"帮助",
    "components" :{ client:Help}
    
 },
 {
    "path" : "/read",
    "name":"阅读协议",
    "components" :{ client:Read}
    
 }, 
 {
    "path":"/",
    "name":"",
    "components":{
        client:Client
    },
        children:[
            {
                "path" : "/crowd",
                "name":"众筹",
                "components" :{ index:Crowd},
                children:[
                    {
                        "path" : "/xieyi",
                        "name":"众筹协议",
                        "components" :{ zhongchou:Xieyi}
                     },
                     {
                        "path" : "/crowd",
                        "name":"众筹首页",
                        "components" :{ zhongchou:Shouye}
                     },
                    {
                        path:"/crowddetailes",
                        components:{zhongchou:Crowdde},
                        name:"众筹详情"
                    },
                    {
                        path:"/tobuy",
                        components:{zhongchou:Tobuy},
                        name:"去买"
                    },
                    {
                        path:"/apply",
                        components: {
                            zhongchou:Apply
                        },
                        name:"申请"
                    },
                    {
                        "path" : "/mycrowd",
                        "name":"我的众筹",
                        "components" :{ zhongchou:Mycrowd}
                     },
                    

                ]
             }
        ]
},
{
    "path":"/",
    "name":"",
    "components":{
        client:Client
    },
        children:[
            {
                "path" : "/hot",
                "name":"热销榜单",
                "components" :{ index:Hot}
             }
        ]
},
{
    "path":"/",
    "name":"",
    "components":{
        client:Client
    },
        children:[
            {
                "path" : "/news",
                "name":"新品上架",
                "components" :{ index:News} 
             }
        ]
},
{
    "path":"/",
    "name":"",
    "components":{
        client:Client
    },
        children:[
            {
                "path" : "/silde",
                "name":"silde",
                "components" :{ index:Silde1}
             }
        ]
}
 
 
 
//   {
//     "path":"/login",
//     "name":"",
//     "components":{
//         logres:Logins
//     }
//  },
//  {
//     "path":"/resgister",
//     "name":"",
//     "components":{
//         logres:Resgister
//     }
//  }


]

const router = new VueRouter( {routes, mode:"history"} )


// router.beforeEach((to,from,next) =>{
 
//       //用vuex里的方法
   
//       //判断store.gettes.isLogin ===false; 就进来
//   console.log("路由改了");
//   console.log(to);
//   console.log(from);
//   next();
//   //     if(to.path== '/login' || '/register'){
   
//   //         //如果是这两个的话就让它正常的显示
   
//   //         next();
   
//   //     }else{
//   //    alert("还没有登录,请先登录,或者注册");
//   //       next('/login')
//   //    }
// })

export default router;

